# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=apptainer
pkgver=1.0.3
pkgrel=0
pkgdesc="Apptainer - application containers for Linux"
url="https://apptainer.org/"
# aarch64: segmentation fault during build
# ppc64le: produces a non-PIE suid binary
arch="all !aarch64 !ppc64le"
license="Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause-LBNL AND MIT AND MPL-2.0 AND Unlicense"
options="suid !check" # no test suite from upstream
depends="squashfs-tools"
makedepends="
	bash
	cni-plugins
	cryptsetup
	go
	libseccomp-dev
	"
subpackages="$pkgname-doc $pkgname-bash-completion"
source="https://github.com/apptainer/apptainer/releases/download/v$pkgver/apptainer-$pkgver.tar.gz"

export GOPATH="$srcdir"
export GOFLAGS="$GOFLAGS -modcacherw -trimpath"

prepare() {
	default_prepare
	echo "$pkgver" > "$builddir"/VERSION
}

build() {
	# override git dir so it picks up our version above
	GIT_DIR=. ./mconfig \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/infodir \
		--localstatedir=/var \
		--without-network

	make -C builddir GOFLAGS="$GOFLAGS"
}

package() {
	make -C builddir DESTDIR="$pkgdir" GOFLAGS="$GOFLAGS" install

	install -Dm644 -t "$pkgdir"/usr/share/doc/$pkgname README.md
}

sha512sums="
93ebe5abce32f35d56fe7d0f818703961cb7f7115965bad387fc895a275d45b569efeecf57ab5778457732233caa57651cd011a3bcac5ed5aaf2dd665082d959  apptainer-1.0.3.tar.gz
"
